
package laboratorio;

public class Complex {
    public double real;
    public double ima;


    
    void Complex()    {        
    }
    
    void Complex(double r, double i)    {
        real=r;
        ima=i;
    }
    public void setReal (double val) {
        this.real = val;
    }
    
     public double getReal () {
        return real;
    }
     
     public void setIma (double val) {
        this.ima = val;
    }
    
     public double getIma () {
        return ima;
    }
     
     
     public Complex suma(Complex x,Complex y){        
        Complex z= new Complex();
        z.real= x.real+y.real;        
        z.ima=x.ima+y.ima;
        
        return z;
    }
     
     public Complex resta(Complex x,Complex y){        
        Complex z= new Complex();
        z.real= x.real-y.real;        
        z.ima=x.ima-y.ima;
        
        return z;
    }
     
     public Complex multiplicacion(Complex x,Complex y){        
        Complex z= new Complex();
        z.real= (x.real*y.real)-(x.ima*y.ima);        
        z.ima=(x.real*y.ima)+(y.real*x.ima);
        
        return z;
    }
          
     public Complex division(Complex x,Complex y){        
        Complex z= new Complex();
        z.real= ((x.real*y.real)+(x.ima*y.ima))/(y.real*y.real+ y.ima*y.ima );
        z.ima=((y.real*x.ima)-(x.real*y.ima))/(y.real*y.real+ y.ima*y.ima );        
        return z;
    }
     
}
